//
//  BRSelectCityCell.m
//  carcareIOS
//
//  Created by 王然 on 16/8/3.
//  Copyright © 2016年 chezheng. All rights reserved.
//

#import "BRSelectCityCell.h"

#define CELL_HEIGHT (45)

#define TitltL_Color (COLOR_HEXSTRING(@"#424242"))

@interface BRSelectCityCell()

@property (nonatomic , strong) UILabel * titleL;

@property (nonatomic , strong) UIImageView * rightClickImageV;//向右侧箭头imageV
@property (nonatomic , strong) UIImageView * rightYesChoiceImageV;//右侧对号选择
@property (nonatomic , strong) UIView * lineView;

@property (nonatomic) BOOL isClickSelf;

@end

@implementation BRSelectCityCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.isClickSelf = NO;
        [self createUI];
    }
    return self;
}
- (void)createUI
{
    CGFloat labelX = 15 * __MAIN_RATIO_375;
    
    UIImage * rightImage = ImageNamed(@"cell_right");
    self.rightClickImageV = [[UIImageView imageViewWithCenter:CGPointMake(__MAIN_WIDTH - labelX - rightImage.size.width / 2 , CELL_HEIGHT / 2) image:rightImage] setupOnView:self];
    [self.rightClickImageV setHidden:YES];
    
    UIImage * yesImage = ImageNamed(@"choiceCityRightImage");
    CGFloat yesIamgeVCenterX = __MAIN_WIDTH - yesImage.size.width / 2 - 10 * __MAIN_RATIO_375;
    self.rightYesChoiceImageV = [[UIImageView imageViewWithCenter:CGPointMake(yesIamgeVCenterX, CELL_HEIGHT / 2) image:yesImage] setupOnView:self];
    [self.rightYesChoiceImageV setHidden:YES];
    
    CGFloat titleLW = __MAIN_WIDTH - rightImage.size.width - labelX * 3;
    self.titleL = [[UILabel labelWithFrame:CGRectMake(labelX, 0, titleLW, CELL_HEIGHT) font:FONT_DEFAULT_Light(15) text:@"" textColor:TitltL_Color] setupOnView:self];
    
    CGFloat lineX = 10 * __MAIN_RATIO_375;
    self.lineView = [[[UIView viewWithFrame:CGRectMake(lineX, CELL_HEIGHT , __MAIN_WIDTH - lineX , 0.5)] setupOnView:self] resetBackgroundColor:[Theme lineColor]];
    [self.lineView setHidden:YES];
}
- (void)reloadTitle:(NSString *)title isClick:(BOOL)isClick rightClickImageVShow:(BOOL)rightClickShow
{
    self.titleL.text = title;
    [self.rightClickImageV setHidden:!rightClickShow];
    [self reloadCellClickColor:isClick];
}
//返回是否被点击了
- (BOOL)returnIsClick
{
    return self.isClickSelf;
}
//传入是否需要点击
- (void)reloadCellClickColor:(BOOL)isClick
{
    self.isClickSelf = isClick;
    self.titleL.textColor = (isClick ? [Theme mainNavColor] :TitltL_Color);
    [self.rightYesChoiceImageV setHidden:((isClick && (!self.rightClickImageV.hidden) ? YES : (!isClick)))];
}
- (void)setIsHiddenLine:(BOOL)isHiddenLine
{
    [self.lineView setHidden:isHiddenLine];
}
+ (CGFloat)getCellHeight
{
    return CELL_HEIGHT;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
